﻿#pragma once

#include "../../../common/utils/BinaryFileReader.h"
#include "../../../common/utils/BinaryFileWriter.h"
#include <thread>

struct SwsContext;
class PixelFormatConversionTool
{

public:
	enum PIXFMT
	{
		YUV420P,
		RGB24,
		RGBA,
		ARGB
	};
	bool Init(
		int src_width,
		int src_height,
		int target_width,
		int target_height,
		std::string in_filename,
		std::string out_filename,
		PIXFMT in_pix_fmt,
		PIXFMT out_pix_fmt
	);
	bool Close();
	bool Start();
	static PixelFormatConversionTool* Create()
	{
		return new PixelFormatConversionTool();
	}
	PixelFormatConversionTool();
	~PixelFormatConversionTool();

public:
	PIXFMT in_pix_fmt = PIXFMT::YUV420P;//
	PIXFMT out_pix_fmt = PIXFMT::RGBA;//
private:
	BinaryFileReader* reader = nullptr;
	BinaryFileWriter* writer = nullptr;
	bool isRunning = true;
	char* inData = nullptr;
	int srcWidth;
	int srcHeight;
	int targetWidth;
	int targetHeight;
	std::string inFilename;
	std::string outFilename;
	PIXFMT inPixFmt;
	PIXFMT outPixFmt;
	//开始转换
	SwsContext* sc = nullptr;
};
